<?php
class UploadAttachWidget extends Widget{

	public function render($data){
		//默认参数
		$var['callback']	=	'attach_upload_success';
		$var['type']		=	'attach';
		$var['l_button']	=	'浏 览';
		$var['l_loading']	=	'正在上传...';
		$var['l_succes']	=	'上传完成.';
		$var['limit']       =   10;

		if(!isset($data['limit'])){
			$var['limit']       =   10;
		}else{
			$var['limit']       =   $data['limit'];
		}

		if(!isset($data['allow_exts'])){
			$allow_exts			=	model('Xdata')->get('site:attach_type');
			$var['allow_exts']	=	$allow_exts;
		}else{
			$var['allow_exts']	=   $data['allow_exts'];
		}
		

		$adata	=	unserialize($data['edit']);
		if(is_array($adata)){
			foreach($adata as $d){
				$ids[]	=	$d['id'];
			}
			unset($adata,$d);
			$var['editdata']	=	X('Xattach')->getAttach($ids);
		}
 		//合并参数
		$var	=	array_merge($var,$data);
        $content = $this->renderFile(dirname(__FILE__)."/UploadAttach.html",$var);
		unset($var,$data);
        return $content;
    }
}
?>